#include <hxcpp.h>

#ifndef INCLUDED_cpp_CppInt32__
#include <cpp/CppInt32__.h>
#endif
#ifndef INCLUDED_haxe_Int64
#include <haxe/Int64.h>
#endif
#ifndef INCLUDED_haxe_io_Bytes
#include <haxe/io/Bytes.h>
#endif
#ifndef INCLUDED_haxe_io_BytesInput
#include <haxe/io/BytesInput.h>
#endif
#ifndef INCLUDED_haxe_io_Input
#include <haxe/io/Input.h>
#endif
#ifndef INCLUDED_jax_io_JCloseable
#include <jax/io/JCloseable.h>
#endif
#ifndef INCLUDED_jax_io_JInputStream
#include <jax/io/JInputStream.h>
#endif
#ifndef INCLUDED_jax_lang_JAutoClosable
#include <jax/lang/JAutoClosable.h>
#endif
namespace jax{
namespace io{

Void JInputStream_obj::__construct(::haxe::io::Input ntv)
{
{
	HX_SOURCE_POS("Source/jax/io/JInputStream.hx",10)
	this->_ntv = ntv;
}
;
	return null();
}

JInputStream_obj::~JInputStream_obj() { }

Dynamic JInputStream_obj::__CreateEmpty() { return  new JInputStream_obj; }
hx::ObjectPtr< JInputStream_obj > JInputStream_obj::__new(::haxe::io::Input ntv)
{  hx::ObjectPtr< JInputStream_obj > result = new JInputStream_obj();
	result->__construct(ntv);
	return result;}

Dynamic JInputStream_obj::__Create(hx::DynamicArray inArgs)
{  hx::ObjectPtr< JInputStream_obj > result = new JInputStream_obj();
	result->__construct(inArgs[0]);
	return result;}

hx::Object *JInputStream_obj::__ToInterface(const type_info &inType) {
	if (inType==typeid( ::jax::io::JCloseable_obj)) return operator ::jax::io::JCloseable_obj *();
	if (inType==typeid( ::jax::lang::JAutoClosable_obj)) return operator ::jax::lang::JAutoClosable_obj *();
	return super::__ToInterface(inType);
}

int JInputStream_obj::availiable( ){
	HX_SOURCE_PUSH("JInputStream_obj::availiable")
	HX_SOURCE_POS("Source/jax/io/JInputStream.hx",14)
	::haxe::io::Bytes bytes = this->_ntv->readAll(null());
	HX_SOURCE_POS("Source/jax/io/JInputStream.hx",15)
	this->_ntv = ::haxe::io::BytesInput_obj::__new(bytes,null(),null());
	HX_SOURCE_POS("Source/jax/io/JInputStream.hx",16)
	return bytes->length;
}


HX_DEFINE_DYNAMIC_FUNC0(JInputStream_obj,availiable,return )

int JInputStream_obj::read( Array< int > b,::cpp::CppInt32__ off,::cpp::CppInt32__ len){
	HX_SOURCE_PUSH("JInputStream_obj::read")
	HX_SOURCE_POS("Source/jax/io/JInputStream.hx",18)
	if (((b == null()))){
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",21)
		return this->_ntv->readByte();
	}
	else{
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",23)
		{
			HX_SOURCE_POS("Source/jax/io/JInputStream.hx",23)
			int _g1 = ::cpp::CppInt32___obj::toInt(off);
			int _g = ::cpp::CppInt32___obj::toInt(len);
			HX_SOURCE_POS("Source/jax/io/JInputStream.hx",23)
			while(((_g1 < _g))){
				HX_SOURCE_POS("Source/jax/io/JInputStream.hx",23)
				int i = (_g1)++;
				HX_SOURCE_POS("Source/jax/io/JInputStream.hx",24)
				b[i] = this->_ntv->readByte();
			}
		}
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",26)
		return b->length;
	}
	HX_SOURCE_POS("Source/jax/io/JInputStream.hx",18)
	return (int)0;
}


HX_DEFINE_DYNAMIC_FUNC3(JInputStream_obj,read,return )

::haxe::Int64 JInputStream_obj::skip( ::haxe::Int64 n){
	HX_SOURCE_PUSH("JInputStream_obj::skip")
	HX_SOURCE_POS("Source/jax/io/JInputStream.hx",30)
	while((!(::cpp::CppInt32___obj::isNeg(n->high)))){
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",31)
		this->_ntv->readByte();
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",32)
		n = ::haxe::Int64_obj::sub(n,::haxe::Int64_obj::__new(::cpp::CppInt32___obj::ofInt((int)0),::cpp::CppInt32___obj::ofInt((int)1)));
	}
	HX_SOURCE_POS("Source/jax/io/JInputStream.hx",34)
	return n;
}


HX_DEFINE_DYNAMIC_FUNC1(JInputStream_obj,skip,return )

Void JInputStream_obj::close( ){
{
		HX_SOURCE_PUSH("JInputStream_obj::close")
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",36)
		this->_ntv->close();
	}
return null();
}


HX_DEFINE_DYNAMIC_FUNC0(JInputStream_obj,close,(void))

Void JInputStream_obj::mark( ){
{
		HX_SOURCE_PUSH("JInputStream_obj::mark")
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",40)
		this->_mark = this->_ntv->readAll(null());
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",41)
		this->reset();
	}
return null();
}


HX_DEFINE_DYNAMIC_FUNC0(JInputStream_obj,mark,(void))

bool JInputStream_obj::markSupported( ){
	HX_SOURCE_PUSH("JInputStream_obj::markSupported")
	HX_SOURCE_POS("Source/jax/io/JInputStream.hx",43)
	return true;
}


HX_DEFINE_DYNAMIC_FUNC0(JInputStream_obj,markSupported,return )

Void JInputStream_obj::reset( ){
{
		HX_SOURCE_PUSH("JInputStream_obj::reset")
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",47)
		this->_ntv->close();
		HX_SOURCE_POS("Source/jax/io/JInputStream.hx",48)
		this->_ntv = ::haxe::io::BytesInput_obj::__new(this->_mark,null(),null());
	}
return null();
}


HX_DEFINE_DYNAMIC_FUNC0(JInputStream_obj,reset,(void))


JInputStream_obj::JInputStream_obj()
{
}

void JInputStream_obj::__Mark(HX_MARK_PARAMS)
{
	HX_MARK_BEGIN_CLASS(JInputStream);
	HX_MARK_MEMBER_NAME(_ntv,"_ntv");
	HX_MARK_MEMBER_NAME(_mark,"_mark");
	HX_MARK_END_CLASS();
}

void JInputStream_obj::__Visit(HX_VISIT_PARAMS)
{
	HX_VISIT_MEMBER_NAME(_ntv,"_ntv");
	HX_VISIT_MEMBER_NAME(_mark,"_mark");
}

Dynamic JInputStream_obj::__Field(const ::String &inName,bool inCallProp)
{
	switch(inName.length) {
	case 4:
		if (HX_FIELD_EQ(inName,"_ntv") ) { return _ntv; }
		if (HX_FIELD_EQ(inName,"read") ) { return read_dyn(); }
		if (HX_FIELD_EQ(inName,"skip") ) { return skip_dyn(); }
		if (HX_FIELD_EQ(inName,"mark") ) { return mark_dyn(); }
		break;
	case 5:
		if (HX_FIELD_EQ(inName,"_mark") ) { return _mark; }
		if (HX_FIELD_EQ(inName,"close") ) { return close_dyn(); }
		if (HX_FIELD_EQ(inName,"reset") ) { return reset_dyn(); }
		break;
	case 10:
		if (HX_FIELD_EQ(inName,"availiable") ) { return availiable_dyn(); }
		break;
	case 13:
		if (HX_FIELD_EQ(inName,"markSupported") ) { return markSupported_dyn(); }
	}
	return super::__Field(inName,inCallProp);
}

Dynamic JInputStream_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp)
{
	switch(inName.length) {
	case 4:
		if (HX_FIELD_EQ(inName,"_ntv") ) { _ntv=inValue.Cast< ::haxe::io::Input >(); return inValue; }
		break;
	case 5:
		if (HX_FIELD_EQ(inName,"_mark") ) { _mark=inValue.Cast< ::haxe::io::Bytes >(); return inValue; }
	}
	return super::__SetField(inName,inValue,inCallProp);
}

void JInputStream_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("_ntv"));
	outFields->push(HX_CSTRING("_mark"));
	super::__GetFields(outFields);
};

static ::String sStaticFields[] = {
	String(null()) };

static ::String sMemberFields[] = {
	HX_CSTRING("_ntv"),
	HX_CSTRING("_mark"),
	HX_CSTRING("availiable"),
	HX_CSTRING("read"),
	HX_CSTRING("skip"),
	HX_CSTRING("close"),
	HX_CSTRING("mark"),
	HX_CSTRING("markSupported"),
	HX_CSTRING("reset"),
	String(null()) };

static void sMarkStatics(HX_MARK_PARAMS) {
};

static void sVisitStatics(HX_VISIT_PARAMS) {
	HX_VISIT_MEMBER_NAME(JInputStream_obj::__mClass,"__mClass");
};

Class JInputStream_obj::__mClass;

void JInputStream_obj::__register()
{
	Static(__mClass) = hx::RegisterClass(HX_CSTRING("jax.io.JInputStream"), hx::TCanCast< JInputStream_obj> ,sStaticFields,sMemberFields,
	&__CreateEmpty, &__Create,
	&super::__SGetClass(), 0, sMarkStatics, sVisitStatics);
}

void JInputStream_obj::__boot()
{
}

} // end namespace jax
} // end namespace io
